package com.qfoud.edu.framwork;

import javax.servlet.ServletContextEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @author xiaobobo
 * @title: Test001
 * @projectName cd-java-2303-project-parent
 * @description: TODO
 * @date 2023/5/8  14:50
 */
public class Test001 {
    /**
     * 找到class文件的class对象然后放到集合中
     * @param fileList
     * @return
     */
    private static List<Class> listClass(List<File> fileList) {
        //首先申明容器
        List<Class> classes=new ArrayList<>();

        //首先准备我们的部署的根路径
        String realPath = "G:\\apache-tomcat-9.0.2\\webapps\\ROOT\\com\\qfoud\\aunt\\commons\\controller";
        //中间经历无数个步骤
        for (File file:fileList) {
            //获取当前文件的绝对路径
            String absolutePath = file.getAbsolutePath();
            // G:/部署根路径/   com/efoud/aunt/commons/controller/UserController    .class

//            String classPath = absolutePath.replace(realPath, "").substring(0, absolutePath.lastIndexOf(".class") - 1).replace("\\", ".");

            String classPath = absolutePath.replace(realPath, "");
            String substring = classPath.substring(0, classPath.lastIndexOf(".class") - 1);
            String substring1 = substring.substring(1);
            String replace = substring1.replace("\\", ".");

            System.out.println("路径是:"+replace);
        }


        return classes;
    }



    public static void main(String[] args){
        String path="G:\\apache-tomcat-9.0.2\\webapps\\ROOT\\com\\qfoud\\aunt\\commons\\controller\\com\\qfoud\\aunt\\commons\\controller\\UserController.class";

        File file = new File(path);

        List<File> xxx=new ArrayList<>();
        xxx.add(file);

        listClass(xxx);


    }



}
